/*
 * @Description: 
 * @FilePath: \hk-computerRoom-Security\src\api\role\index.ts
 * @Date: 2023-07-27 14:16:15
 * @LastEditTime: 2024-01-04 10:43:26
 */
import axiosRequest from '/@/utils/request';

/**
 * （不建议写成 request.post(xxx)，因为这样 post 时，无法 params 与 data 同时传参）
 *
 * 角色管理api接口集合
 * @method  getAllRoleList 查询所有角色
 * @method  getRoleDetailById 获取角色详情
 * @method  getUserRoleList 查询用户拥有的角色
 * @method  addRole 添加角色
 * @method  updateRole 修改角色
 * @method  delRoleDetailById 删除角色
 * @method  assignRole 分配角色
 */
export function useRoleApi() {
  return {
    getAllRoleList: async (params: object) => {
      return await axiosRequest({
        url: '/api/role/pageRole',
        method: 'POST',
        data: params,
      });
    },
    getUserRoleList: async (params: object) => {
      return await axiosRequest({
        url: '/api/role/listUserRole',
        method: 'POST',
        params,
      });
    },
    addRole: async (params: object) => {
      return await axiosRequest({
        url: '/api/role/createRole',
        method: 'POST',
        data: params,
      });
    },
    updateRole: async (params: object) => {
      return await axiosRequest({
        url: '/api/role/updateRole',
        method: 'POST',
        data: params,
      });
    },
    assignRole: async (params: object) => {
      return await axiosRequest({
        url: '/api/role/assignRole',
        method: 'POST',
        data: params,
      });
    },
    getRoleDetailById: async (id: string) => {
      return await axiosRequest({
        url: `/api/role/getRole/${id}`,
        method: 'GET',
      });
    },
    delRoleDetailById: async (id: string) => {
      return await axiosRequest({
        url: `/api/role/deleteRole/${id}`,
        method: 'GET',
      });
    },
  }
}
